Crate ansi_to_tui

source ·
Expand description

Parses a Vec<u8> as an byte sequence with ansi colors to tui::text::Text.

Invalid ansi colors / sequences will be ignored.

Supported features

  • UTF-8 using String::from_utf8 or simdutf8.
  • Most stuff like Bold / Italic / Underline / Strikethrough.
  • Supports 4-bit color palletes.
  • Supports 8-bit color.
  • Supports True color ( RGB / 24-bit color ).

§Example

The argument to the function ansi_to_text implements IntoIterator so it will be consumed on use.

use ansi_to_tui::IntoText;
let bytes = b"\x1b[38;2;225;192;203mAAAAA\x1b[0m".to_owned().to_vec();
let text = bytes.into_text().unwrap();

Example parsing from a file.

use ansi_to_tui::IntoText;
let buffer = std::fs::read("ascii/text.ascii").unwrap();
let text = buffer.into_text().unwrap();

If you want to use simdutf8 instead of String::from_utf8()
for parsing UTF-8 then enable optional feature simd

Enums§

  • This enum stores the error types

Traits§

  • IntoText will convert any type that has a AsRef<u8> to a Text.